using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using UserManagementService.DTOs;

namespace UserManagementService.Organizations;

/// <summary>
/// 组织管理应用服务接口
/// </summary>
public interface IOrganizationAppService : IApplicationService
{
    /// <summary>
    /// 获取组织列表
    /// </summary>
    Task<PagedResultDto<OrganizationDto>> GetListAsync(SearchOrganizationsDto input);

    /// <summary>
    /// 获取组织详情
    /// </summary>
    Task<OrganizationDto> GetAsync(Guid id);

    /// <summary>
    /// 根据编码获取组织
    /// </summary>
    Task<OrganizationDto> GetByCodeAsync(string code);

    /// <summary>
    /// 创建组织
    /// </summary>
    Task<OrganizationDto> CreateAsync(CreateOrganizationDto input);

    /// <summary>
    /// 更新组织
    /// </summary>
    Task<OrganizationDto> UpdateAsync(Guid id, UpdateOrganizationDto input);

    /// <summary>
    /// 删除组织
    /// </summary>
    Task DeleteAsync(Guid id);

    /// <summary>
    /// 移动组织
    /// </summary>
    Task<OrganizationDto> MoveAsync(MoveOrganizationDto input);

    /// <summary>
    /// 移动组织到指定位置
    /// </summary>
    Task<OrganizationDto> MoveOrganizationAsync(Guid id, MoveOrganizationDto input);

    /// <summary>
    /// 启用组织
    /// </summary>
    Task<OrganizationDto> EnableOrganizationAsync(Guid id);

    /// <summary>
    /// 禁用组织
    /// </summary>
    Task<OrganizationDto> DisableOrganizationAsync(Guid id);

    /// <summary>
    /// 获取组织成员列表
    /// </summary>
    Task<PagedResultDto<OrganizationMemberDto>> GetMembersAsync(Guid organizationId, PagedAndSortedResultRequestDto input);

    /// <summary>
    /// 添加组织成员
    /// </summary>
    Task<OrganizationMemberDto> AddMemberAsync(Guid organizationId, AddOrganizationMemberDto input);

    /// <summary>
    /// 更新组织成员
    /// </summary>
    Task<OrganizationMemberDto> UpdateMemberAsync(Guid organizationId, Guid userId, UpdateOrganizationMemberDto input);

    /// <summary>
    /// 移除组织成员
    /// </summary>
    Task RemoveMemberAsync(Guid organizationId, Guid userId);

    /// <summary>
    /// 获取组织统计信息
    /// </summary>
    Task<OrganizationStatisticsDto> GetStatisticsAsync(Guid? organizationId = null);

    /// <summary>
    /// 搜索组织
    /// </summary>
    Task<List<OrganizationDto>> SearchOrganizationsAsync(SearchOrganizationsDto input);

    /// <summary>
    /// 导入组织
    /// </summary>
    Task<OrganizationImportResultDto> ImportOrganizationsAsync(ImportOrganizationsDto input);

    /// <summary>
    /// 导出组织
    /// </summary>
    Task<FileResultDto> ExportOrganizationsAsync(ExportOrganizationsDto input);

    /// <summary>
    /// 获取组织树
    /// </summary>
    Task<List<OrganizationDto>> GetTreeAsync(Guid? parentId = null);

    }

/// <summary>
/// 创建组织DTO
/// </summary>
public class CreateOrganizationDto
{
    public string Name { get; set; }
    public string Code { get; set; }
    public string Description { get; set; }
    public Guid? ParentId { get; set; }
    public int Sort { get; set; }
    public bool IsEnabled { get; set; } = true;
}

/// <summary>
/// 更新组织DTO
/// </summary>
public class UpdateOrganizationDto
{
    public string Name { get; set; }
    public string Description { get; set; }
    public int Sort { get; set; }
    public bool IsEnabled { get; set; }
}